export const monitorConfig = {
  // 系统监控
  system: {
    // 服务器监控
    server: {
      enabled: true,
      interval: 60, // 检测间隔(秒)
      metrics: {
        cpu: {
          warning: 70, // 警告阈值
          critical: 90, // 严重阈值
          samples: 3, // 采样次数
        },
        memory: {
          warning: 80,
          critical: 95,
          includeSwap: true,
        },
        disk: {
          warning: 85,
          critical: 95,
          paths: ['C:', 'D:'], // Windows磁盘
        },
        network: {
          warning: 80, // 带宽使用率
          critical: 95,
          interfaces: ['以太网', 'WLAN'], // 中文网卡名
        },
      },
    },

    // 进程监控
    process: {
      enabled: true,
      targets: [
        {
          name: 'node.exe',
          minCount: 1,
          maxCount: 4,
          memoryLimit: 2048, // MB
        },
        {
          name: 'ffmpeg.exe',
          maxCount: 50,
          cpuLimit: 80, // CPU使用率
        },
        {
          name: 'redis-server.exe',
          minCount: 1,
          restartOnCrash: true,
        },
      ],
    },
  },

  // 业务监控
  business: {
    // 直播监控
    streaming: {
      enabled: true,
      checks: {
        delay: {
          warning: 3000, // 延迟警告(ms)
          critical: 8000,
        },
        quality: {
          minBitrate: 500000, // 最低码率
          minFps: 24, // 最低帧率
        },
        concurrent: {
          warning: 800, // 并发警告
          critical: 1000,
        },
      },
    },

    // 支付监控
    payment: {
      enabled: true,
      alerts: {
        failureRate: 0.05, // 失败率阈值
        responseTime: 5000, // 响应时间(ms)
        suspiciousAmount: 10000, // 可疑金额(元)
      },
      providers: ['alipay', 'wechat'],
    },
  },

  // 告警通知
  alert: {
    // 通知渠道
    channels: [
      {
        type: 'email',
        enabled: true,
        template: 'D:\\livechat\\templates\\alert_email.html',
        smtp: {
          host: 'smtp.qq.com',
          port: 465,
          secure: true,
          auth: {
            user: process.env.SMTP_USER,
            pass: process.env.SMTP_PASS,
          },
        },
      },
      {
        type: 'sms',
        enabled: true,
        provider: 'aliyun',
        template: 'SMS_123456789',
        sign: '直播平台',
      },
      {
        type: 'dingtalk', // 钉钉机器人
        enabled: true,
        webhook: process.env.DINGTALK_WEBHOOK,
        secret: process.env.DINGTALK_SECRET,
      },
      {
        type: 'wecom', // 企业微信
        enabled: true,
        webhook: process.env.WECOM_WEBHOOK,
      },
    ],

    // 告警级别
    levels: {
      info: {
        color: '#1890ff',
        channels: ['dingtalk'],
      },
      warning: {
        color: '#faad14',
        channels: ['dingtalk', 'email'],
      },
      critical: {
        color: '#f5222d',
        channels: ['dingtalk', 'email', 'sms'],
      },
    },

    // 告警规则
    rules: {
      aggregation: '5m', // 聚合时间
      silenceDuration: '30m', // 静默时间
      maxAlertsPerDay: 100, // 每日最大告警数
    },
  },

  // 日志配置
  logging: {
    // 日志存储
    storage: {
      path: 'D:\\livechat\\logs\\monitor',
      rotate: {
        size: '100M',
        keep: 30,
        compress: true,
      },
    },
    // 日志格式
    format: {
      timestamp: true,
      level: true,
      source: true,
      detail: true,
    },
  },
}
